Skip to main content

File list

Description

<jp-file-list> is a component with functionality of <input multiple type="file">, but also supports initial value in form of urls.


Attributes

NameRequiredTypeDescription
valuestring (list of urls separated by comma)setter
labelstring (HTML)displayed above the field
idstringunique identifier
namestringname of the form control
serviceFileServicefile service
sortablebooleanenables/disables drag and drop sort
maxfilesnumbermaximum number of files allowed
maxfilesValidationMessagestringvalidation message for when component does not satisfy maxfiles
minfilesnumberminimum number of files allowed
minfilesValidationMessagestringvalidation message for when component does not satisfy minfiles
validationMessages{[type]: string} where type is stringcompact way of writing validation messages in a single attribute


Interfaces

FileService

Defines the accepted file types and provides a method to upload a file.



Properties
NameRequiredTypeDescription
acceptedFilesstringdefines acceptable file types
maxSizenumbermax file size in bytes
uploadFile(file: any, id?: string) => Promise<string>uploads a file and returns a promise
which is a string that represents a link to the file location


Slots

This component does not have any slots.



Methods

  • getValue
    • returns form field value
  • reportValidity
    • triggers reportValidity
  • save
    • async function that saves files and adds urls to value


Events

  • value
    • triggers when files change
  • removed
    • triggers when saved file is removed and contains information about url
  • change
    • triggers when new files are added and contains information about unsaved files
  • rejected
    • triggers when added file is not accepted because it does not satisfy some service criteria


Demo

Live Editor
// import '@jaspero/web-components/file-list.wc.js';
// import '@jaspero/web-components/file-list.css';

<jp-file-list></jp-file-list>
Result
Loading...